Lockless distributed redundant storage and nvram caching of compressed data in a highly-distributed shared topology with direct memory access capable interconnect

ABSTRACT

A system for data storage includes multiple servers, which are configured to communicate over a network with multiple multi-queue storage devices and with at least one storage controller, to store on the storage devices compressed data belonging to a user volume, to specify storage locations, in which the compressed data is stored on the storage devices, in a shared data structure that is shared and modified by the servers using remote direct memory access, and to coordinate access to the compressed data by the servers by querying the shared data structure, without executing code on a processor of the storage controller.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application claims the benefit of U.S. Provisional PatentApplication 62/146,984, filed Apr. 14, 2015, and U.S. Provisional PatentApplication 62/173,970, filed Jun. 11, 2015, whose disclosures areincorporated herein by reference.

FIELD OF THE INVENTION

The present invention relates generally to data storage, andparticularly to methods and systems for distributed storage.

BACKGROUND OF THE INVENTION

Various techniques for distributed data storage are known in the art.For example, PCT International Publication WO 2013/024485, whosedisclosure is incorporated herein by reference, describes a method ofmanaging a distributed storage space, including mapping a plurality ofreplica sets to a plurality of storage managing modules installed in aplurality of computing units. Each of the plurality of storage managingmodules manages access of at least one storage consumer application toreplica data of at least one replica of a replica set from the pluralityof replica sets. The replica data is stored in at least one drive of arespective computing unit.

U.S. Patent Application Publication 2015/0212752, whose disclosure isincorporated herein by reference, describes a storage system thatincludes a storage processor coupled to solid state disks (SSDs) and ahost. The SSDs are identified by SSD logical block addresses (SLBAs).The storage processor receives a command from the host to write data tothe SSDs and further receives a location within the SSDs to write thedata, the location being referred to as a host LBA. The storageprocessor includes a central processor unit (CPU) subsystem andmaintains unassigned SLBAs of a corresponding SSD. The CPU subsystem,upon receiving the command to write data, generates sub-commands basedon a range of host LBAs derived from the received command and furtherbased on a granularity. The CPU subsystem assigns the sub-commands tounassigned SLBAs by assigning each sub-command to a distinct SSD of astripe, the host LBAs being decoupled from the SLBAs. The CPU subsystemcontinues to assign the sub-commands until all remaining SLBAs of thestripe are assigned, after which it calculates parity for the stripe andsaves the calculated parity to one or more of the SSDs of the stripe.

SUMMARY OF THE INVENTION

An embodiment of the present invention that is described herein providesa method for data storage, including, in a system that includes multipleservers, multiple multi-queue storage devices and at least one storagecontroller that communicate over a network, storing on the storagedevices compressed data belonging to a user volume. Storage locations,in which the compressed data is stored on the storage devices, arespecifies in a shared data structure that is shared and modified by theservers using remote direct memory access. Access to the compressed databy the servers is coordinated by querying the shared data structure,without executing code on a processor of the storage controller.

In some embodiments, storing the compressed data includes compressingdata by the servers, and sending the compressed data for storage on thestorage devices. In some embodiments, storing the compressed dataincludes accumulating data blocks, which include the compressed data, ina Non-Volatile Random-Access Memory (NVRAM) cache that is accessible tothe servers and to the storage devices, so as to form one or morestripes, and transferring the stripes from the NVRAM cache to thestorage devices.

In some embodiments, storing the compressed data includes storingmultiple compressed blocks of compressed data in one or more data blocksof a stripe, and specifying the storage locations includes specifyingmetadata that points to locations of the compressed blocks within thedata blocks. In an embodiment, the metadata is stored in the data blocksof the stripe. In an alternative embodiment, the metadata is stored inthe shared data structure, separately from the data blocks.

In some embodiments, storing the compressed data includes applying abackground compression process, which compresses data that has alreadybeen stored on the storage devices, and updates the shared datastructure so that the servers are able to access the compressed dataconcurrently and without executing code on the storage controller.Applying the background compression process may include reading datafrom one or more data blocks stored on the storage devices, compressingthe read data, and rewriting the compressed data back to the storagedevices. Rewriting the compressed data may include compacting therewritten data by removing regions of invalid data that are present inthe data blocks.

In an embodiment, storing the compressed data includes performingcompression or decompression in Network Interface Controllers (NICs) ofthe servers, the storage devices or the storage controller.

There is additionally provided, in accordance with an embodiment of thepresent invention, a system for data storage, including multipleservers, which are configured to communicate over a network withmultiple multi-queue storage devices and with at least one storagecontroller, to store on the storage devices compressed data belonging toa user volume, to specify storage locations, in which the compresseddata is stored on the storage devices, in a shared data structure thatis shared and modified by the servers using remote direct memory access,and to coordinate access to the compressed data by the servers byquerying the shared data structure, without executing code on aprocessor of the storage controller. The present invention will be morefully understood from the following detailed description of theembodiments thereof, taken together with the drawings in which:

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram that schematically illustrates a computingsystem that uses distributed data storage, in accordance with anembodiment of the present invention;

FIG. 2 is a block diagram that schematically illustrates elements of astorage agent, in accordance with an embodiment of the presentinvention;

FIG. 3 is a diagram that schematically illustrates data structures usedin the computing system of FIG. 1, in accordance with an embodiment ofthe present invention;

FIG. 4 is a flow chart that schematically illustrates a method forperforming a write command, in accordance with an embodiment of thepresent invention;

FIG. 5 is a flow chart that schematically illustrates a method fordestaging RAID stripes from NVRAM cache to persistent storage, inaccordance with an embodiment of the present invention;

FIG. 6 is a flow chart that schematically illustrates a method forpartial destaging of a RAID stripe, in accordance with an embodiment ofthe present invention;

FIG. 7 is a flow chart that schematically illustrates a method forperforming a read command, in accordance with an embodiment of thepresent invention;

FIG. 8 is a diagram that schematically illustrates data structures usedfor in-line caching of compressed data, in accordance with an embodimentof the present invention;

FIG. 9 is a diagram that schematically illustrates data structures usedfor destaging and storing compressed data, in accordance with anembodiment of the present invention; and

FIGS. 10 and 11 are flow charts that schematically illustrate methodsfor background compression, in accordance with embodiments of thepresent invention.

DETAILED DESCRIPTION OF EMBODIMENTS Overview

Embodiments of the present invention that are described herein provideimproved methods and systems for applying data compression in a highlydistributed storage system. The high performance and high level ofdistribution are achieved, for example, by (i) using multi-queue storagedevices and (ii) accessing shared data structures using remote directmemory access.

The disclosed techniques are typically implemented in a computing systemcomprising multiple servers that store data in multiple sharedmulti-queue storage devices, and one or more storage controllers.Computing systems of this sort are described, for example, in U.S.patent applications Ser. Nos. 14/599,510, 14/697,653 and 15/015,157,which are assigned to the assignee of the present patent application andwhose disclosures are incorporated herein by reference.

In such a system, the storage devices are typically multi-queue storagedevices, such as Solid State Drives (SSDs) that operate in accordancewith the NVM Express (NVMe) specification. NVMe is specified, forexample, in “NVM Express,” Revision 1.2, Nov. 3, 2014, and revision1.2a, Oct. 23, 2015, which are incorporated herein by reference. Inthese embodiments, each storage device provides multiple server-specificqueues for storage commands, and has the freedom to queue, schedule andreorder execution of storage commands.

In some embodiments, compression and decompression are performedin-line, as part of the writing and readout processes. In theseembodiments, the servers typically store the compressed data in stripes,each stripe comprising multiple data blocks and one or more redundancy(e.g., parity) blocks. In some embodiments, the system further comprisesa Non-Volatile Random Access Memory (NVRAM) cache that is accessible tothe servers and to the storage devices. Each server accumulates datablocks in the NVRAM cache, until filling a predefined integer number ofstripes, and then transfers (“destages”) the stripes to theserver-specific queues on the storage devices. Each storage device thenautonomously schedules and completes transfer of the data from theserver-specific queues to the non-volatile storage medium. Destaging offull stripes is highly efficient in terms of parity calculations, andeliminates the need to read data blocks in order to update the parityfor every write.

In some embodiments, the data blocks that comprise the compressed databelong to user volumes that are shared among multiple servers. In orderto prevent data inconsistency caused by different servers accessing thesame data block or stripe, the system uses a set of shared datastructures that specify the storage locations of the various data blocksand stripes. The shared data structures are accessible both to thestorage controllers and to the servers.

The disclosed techniques typically make extensive use of remote directmemory access over the communication network. Remote direct memoryaccess is used, for example, by the servers for writing to the NVRAMcache, and for accessing the shared data structures that reside in thestorage controllers' memory. The embodiments described below refermainly to Remote Direct Memory Access (RDMA) protocols, by way ofexample. Various variants of RDMA may be used for this purpose, e.g.,Infiniband (IB), RDMA over Converged Ethernet (RoCE), Virtual InterfaceArchitecture and internet Wide Area RDMA Protocol (iWARP). Furtheralternatively, the disclosed techniques can be implemented using anyother form of direct memory access over a network, e.g., Direct MemoryAccess (DMA), various Peripheral Component Interconnect Express (PCIe)schemes, or any other suitable protocol. In the context of the presentpatent application and in the claims, all such protocols are referred toas “remote direct memory access.”

In this manner, the servers are able to query and update the shared datastructures that reside in the memory of the storage controllers, withouthaving to trigger or run code on the storage controllers. Similarly, theservers are able to write data to the NVRAM cache directly, withouthaving to trigger or run code on the storage controllers or storagedevices.

In various embodiments, the NVRAM cache and the shared data structuresmay be located at any suitable location in the system. The NVRAM cacheand the shared data structures may or may not be collocated. In oneembodiment, the NVRAM cache and the shared data structures are bothlocated in the storage controller memory. Alternatively, for example,the NVRAM cache and/or one or more of the shared data structures may belocated in a memory attached to the storage devices.

In some of the disclosed techniques the servers update the shared datastructures upon writing or destaging, using RDMA atomic Compare and Swap(CAS) commands. By using CAS commands, a given server is able to updatethe shared data structures, and at the same time ensure that the databeing written or destaged was not modified by another server. Thismechanism enables the servers to maintain system-wide data integrity ofshared volumes, without a need for any centralized entity, without aneed to obtain locks on data elements, and without a need for servers tocommunicate with one another for coordination.

Various example storage processes that use the above mechanisms aredescribed herein. Example processes include writing data blocks, readingdata blocks, degraded readout in case of failure of a storage device,destaging stripes from the NVRAM cache to the storage devices,rebuilding stripes following failure of a storage device, redistributingstripes as part of addition or removal of a storage device, and garbagecollection.

Several detailed schemes for in-line caching, destaging and readout ofcompressed data, and associated processes, are described herein.Additionally or alternatively, the system may compress data that hasalready been stored on the storage devices, in a background process.Several techniques for background compression and compaction (“garbagecollection”) are also described.

System Description

FIG. 1 is a block diagram that schematically illustrates a computingsystem 20, in accordance with an embodiment of the present invention.System 20 may comprise, for example, a data center, a High-PerformanceComputing (HPC) cluster, or any other suitable system. System 20comprises multiple servers 24 (also referred to as hosts) denoted S1 . .. Sn, and multiple storage devices 28 denoted D1 . . . Dm. The serversand storage devices are interconnected by a communication network 32.The system further comprises one or more storage controllers 36 thatmanage the storage of data in storage devices 28.

In the disclosed techniques, data-path operations such as writing andreadout are performed directly between the servers and the storagedevices, without having to trigger or run code on the storage controllerCPUs. The storage controller CPUs are involved only in relatively rarecontrol-path operations. Computing systems of this sort are alsodescribed, for example, in U.S. patent applications Ser. Nos.14/599,510, 14/697,653, cited above, and in U.S. patent application Ser.No. 14/794,868, which is assigned to the assignee of the present patentapplication and whose disclosure is incorporated herein by reference.

In the disclosed embodiments, each storage device 28 is a multi-queuestorage device, e.g., an NVMe SSD. Each storage device 28 providesmultiple server-specific queues for storage commands. In other words, agiven storage device 28 queues the storage commands received from eachserver 24 in a separate respective server-specific queue. The storagedevices typically have the freedom to queue, schedule and reorderexecution of storage commands.

In the present example, although not necessarily, storage devices 28 arecomprised in a storage-device enclosure 30, e.g., a rack, drawer orcabinet. Enclosure 30 further comprises a Non-Volatile Random AccessMemory (NVRAM) cache unit 46. Unit 46, referred to herein simply as“NVRAM cache,” is used by servers 24 as a front-end for accumulatingdata in stripes 47, e.g., RAID stripes, before transferring the stripesfor storage in storage devices 28. Transfer of stripes from NVRAM cache46 to storage devices 28 is referred to herein as “destaging.” The useof NVRAM cache 46 is addressed in greater detail below. Enclosure 30 mayalso comprise its own Central Processing Unit (CPU—not shown).

NVRAM cache 46 may be implemented using any suitable NVRAM devices orconfigurations, for example using a volatile memory such as Dynamic RAM(DRAM) or Static RAM (SRAM) that is backed-up by a temporary powersource such as a battery or capacitor. Another non-limiting example onan NVRAM is a DRAM backed-up by a Flash memory.

Storage-related functions in each server 24 are carried out by arespective storage agent 40. Agents 40 typically comprise softwaremodules installed and running on the respective servers. In someembodiments, agent 40 in each server 24 maintains one or more respectivequeues per storage device 28, corresponding to the respectiveserver-specific queues of the storage devices. (For example, in a serverthat comprises multiple CPU cores, agent 40 may maintain a respectivequeue per storage device per CPU core, or per storage device per groupof CPU cores.) Agents 40 and storage devices 28 are permitted to reorderstorage commands in the queues. The queues in a given agent 40 typicallyhave no visibility outside the context of the respective server. Thefunctions of agents 40, and their interaction with NVRAM cache 46,storage devices 28 and storage controllers 36, are described in detailbelow.

Servers 24 may comprise any suitable computing platforms that run anysuitable applications. In the present context, the term “server”includes both physical servers and virtual servers. For example, avirtual server may be implemented using a Virtual Machine (VM) that ishosted in some physical computer. Thus, in some embodiments multiplevirtual servers may run in a single physical computer. Storagecontrollers 36, too, may be physical or virtual. In an exampleembodiment, the storage controllers may be implemented as softwaremodules that run on one or more physical servers 24.

Storage devices 28 may comprise any suitable storage medium, such as,for example, Solid State Drives (SSD), Non-Volatile Random Access Memory(NVRAM) devices or Hard Disk Drives (HDDs). Typically, as explainedabove, storage devices 28 are multi-queue storage devices such as NVMeSSDs. Network 32 may operate in accordance with any suitablecommunication protocol, such as Ethernet or Infiniband. As explainedabove, and will be demonstrated in detail below, the disclosedtechniques are typically implemented using RDMA, DMA or similar remotedirect memory access schemes.

Generally, system 20 may comprise any suitable number of servers,storage devices and storage controllers. In the present example, thesystem comprises two storage controllers denoted C1 and C2, forresilience. One of the storage controllers is defined as primary, whilethe other controller serves as hot backup and can replace the primarystorage controller in case of failure.

In the embodiments described herein, the assumption is that any server24 is able to communicate with any storage device 28, but there is noneed for the servers to communicate with one another. Storagecontrollers 36 are assumed to be able to communicate with all servers 24and storage devices 28, as well as with one another.

The configuration of system 20 shown in FIG. 1 is an exampleconfiguration, which is chosen purely for the sake of conceptualclarity. In alternative embodiments, any other suitable systemconfiguration can be used. For example, NVRAM cache unit 46 may belocated in any other suitable location in the system, not necessarilycoupled to storage devices 28.

The different system elements may be implemented using suitablehardware, using software, or using a combination of hardware andsoftware elements. Each server 24 typically comprises a suitable networkinterface for communicating over network 32, e.g., with the NVRAM cache,storage devices and/or storage controllers, and a suitable processorthat carries out the various server functions. Each storage controller36 typically comprises a suitable network interface for communicatingover network 32, e.g., with the storage devices and/or servers, and asuitable processor that carries out the various storage controllerfunctions.

In some embodiments, servers 24 and/or storage controllers 36 comprisegeneral-purpose processors, which are programmed in software to carryout the functions described herein. The software may be downloaded tothe processors in electronic form, over a network, for example, or itmay, alternatively or additionally, be provided and/or stored onnon-transitory tangible media, such as magnetic, optical, or electronicmemory.

FIG. 2 is a block diagram that schematically illustrates elements ofstorage agent 40, in accordance with an embodiment of the presentinvention. A respective storage agent of this sort typically runs oneach server 24 and performs storage-related functions for userapplications 44 running on the server. As noted above, servers 24 maycomprise physical and/or virtual servers. Thus, a certain physicalcomputer may run multiple virtual servers 24, each having its ownrespective storage agent 40.

In the disclosed embodiments, each storage agent 40 comprises aRedundant Array of Independent Disks (RAID) layer 48 and a user-volumelayer 52. RAID layer 48 carries out a redundant storage scheme overstorage devices 28, including handling storage resiliency, detection ofstorage device failures, rebuilding of failed storage devices andrebalancing of data in case of maintenance or other evacuation of astorage device. RAID layer 48 also typically stripes data acrossmultiple storage devices 28 for improving storage performance.

In one simple example embodiment, RAID layer 48 implements a RAID-10scheme, i.e., replicates and stores two copies of each data item on twodifferent storage devices 28. One of the two copies is defined asprimary and the other as secondary. The primary copy is used for readoutas long as it is available. If the primary copy is unavailable, forexample due to storage-device failure, the RAID layer reverts to readthe secondary copy. Other examples described below use RAID-6, in whichdata is stored in stripes that each comprises multiple data blocks andtwo parity blocks.

Alternatively, RAID layer 48 may implement any other suitable redundantstorage scheme (RAID-based or otherwise), such as schemes based onerasure codes. The description that follows uses the terms “redundancy”and “parity” interchangeably. The redundancy or parity may be calculatedover the data in any suitable way, such as using XOR or a suitable errorcorrection code. In some embodiments, a T10-PI scheme or otherdata-integrity protection scheme may be implemented on top of theredundant storage scheme.

RAID layer 48 accesses storage devices 28 using physical addressing. Inother words, RAID layer 48 exchanges with storage devices 28 read andwrite commands, as well as responses and retrieved data, which directlyspecify physical addresses (physical storage locations) on the storagedevices. In this embodiment, all logical-to-physical addresstranslations are performed in agents 40 in the servers, and none in thestorage devices.

The RAID layer maps between physical addresses and Logical Volumes (LVs)to be used by user-volume layer 52. In a RAID-10 configuration, forexample, each LV is mapped to two or more physical-address ranges on twoor more different storage devices. The two or more ranges are used forstoring the replicated copies of the LV data as part of the redundantstorage scheme.

The redundant storage scheme (e.g., RAID) is thus hidden fromuser-volume layer 52. Layer 52 views the storage medium as a set ofguaranteed-storage LVs. User-volume layer 52 is typically unaware ofstorage device failure, recovery, maintenance and rebuilding, which arehandled transparently by RAID layer 48. (Nevertheless, someoptimizations may benefit from such awareness by layer 52. For example,there is no need to rebuild unallocated storage space.)

User-volume layer 52 provides storage resources to applications 44 byexposing user volumes that are identified by respective Logical UnitNumbers (LUNs). The terms “user volume” and “LUN” are usedinterchangeably herein. In other words, a user application 44 views thestorage system as a collection of user volumes, and issues storagecommands having user-volume addresses.

Storage agent 40 translates between the different address spaces using aRAID table 56 and a volume map 60. RAID table 56 holds the translationbetween LV addresses and physical addresses, and volume map 60 holds thetranslation between user-volume addresses and LV addresses.

In the embodiments described herein, the user-volume addresses are alsoreferred to as User Block Addresses (UBAs) and the LV addresses are alsoreferred to as RAID Block Addresses (RBAs). Thus, RAID layer 48 in eachserver 24 translates between UBAs and RBAs.

In the description that follows, the basic storage unit in the RBA spaceis a RAID page, e.g., a 512 B, 4 KB or 32 KB page, for example. Theterms “page” and “block” are used interchangeably herein. In alternativeembodiments, any suitable page size can be used. Each RAID page has arespective RAID Page Descriptor (RPD). The RPD of a RAID page specifieswhether the RAID page is currently cached in NVRAM cache 46 or stored instorage devices 28, and the exact location of the RAID page in the cacheor on the storage devices.

In some embodiments, the overall RBA space is divided into two or morechunks of size CS, and the disclosed technique may be applied separatelyper chunk. This implementation reduces the address space within eachchunk, and therefore reduces the number of bits required to addressmemory blocks. The total memory size required for storing metadata isthus reduced. In some embodiments such chunks may be assigned adaptivelyto servers 24, e.g., for distributing background tasks such as garbagecollection.

Typically, any server 24 may attach to any user volume. A given uservolume may have multiple servers attached thereto. In some embodiments,storage controllers 36 define and maintain a global volume map thatspecifies all user volumes in system 20. Volume map 60 in each storageagent 40 comprises a locally-cached copy of at least part of the globalvolume map. In agent 40 of a given server, volume map 60 holds at leastthe mapping of the user volumes (LUNs) to which this server is attached.In an embodiment, volume map 60 supports thin provisioning.

Certain aspects of distributed storage systems of the sort shown inFIGS. 1 and 2 are also addressed in U.S. patent application Ser. Nos.14/599,510, 14/697,653 and 14/794,868, cited above.

NVRAM Cache Considerations

In some embodiments, each server 24 is assigned a respective area inNVRAM cache 46 for storing a respective set of RAID stripes 47. Servers24 typically write to and read from NVRAM cache 46 using RDMA. The areasassigned to servers S1, S2, . . . , Sn are shown in FIG. 1 as “'S1stripes”, “S2 stripes”, . . . , “Sn stripes”, respectively. Each RAIDstripe has a respective RAID Stripe Descriptor (RSD).

Typically, storage controllers 36 assign each agent 40 a pool of freeNVRAM cache pages. Agent 40 obtains additional free NVRAM cache pagesfrom the storage controllers as needed. Agent 40 of each server 24 usesits assigned area as a write combining cache, i.e., graduallyaccumulates data pages that are en-route to storage.

The NVRAM cache area of a given server is typically distributed overmultiple failure domains. Agent 40 typically acknowledges completion ofa write command only after at least two copies of the data page inquestion have been cached in NVRAM cache pages on at least two failuredomains. Depending on system requirements, a larger number of copies maybe stored.

Typically, each agent 40 manages its respective area in NVRAM cache 46.Among other management tasks, agents 40 perform a “cleanup” process,e.g., upon server failure or unmapping. This process is described below.

The size of a stripe is N+C pages, wherein N denotes the number of datapages per stripe, and C denotes the number of redundancy pages perstripe. The size of the cache area assigned to a given server istypically a multiple of the stripe size, at least a single stripe andtypically several stripes. A large cache area per server allows agent 40to accumulate several stripes before destaging them to storage devices28, thereby improving performance. In Flash-based storage devices, forexample, accumulating several stripes may allow destaging at agranularity of the erasure-block or clustered-block of the storagedevice, so as to considerably improve the endurance and performance ofthe storage device. In some embodiments, a larger NVRAM cache with somereplacement policy (e.g., Least Recently Used—LRU) may also beimplemented.

As will be described below, in some embodiments NVRAM cache 46 is alsoused as a read cache, e.g., for reducing read latency and increasingstorage throughput. Each server typically manages its read cacheseparately and autonomously using RDMA, using some replacement policysuch as LRU. Each server may perform garbage collection to its readcache, to remove memory pages that are no longer referenced.

In some embodiments, when the CPU of a server comprises multiple CPUcores, an NVRAM cache area may be assigned separately to each CPU core,for reducing contention on the server side.

In some embodiments, NVRAM cache 46 may be distributed among storagedevices 28, e.g., by equally splitting the cache among the storagedevice and allocating an equal portion on each storage device, whilepreserving the replication on different failure domains. In otherembodiments, NVRAM cache 46 may reside, in a mirrored configuration, onstorage controllers 36. As yet another example, NVRAM cache 46 may bedistributed among servers 24, again preserving replication on differentfailure domains.

Typically, each memory page in NVRAM cache 46 (referred to as a “NVRAMcache page” or “cache page”) has a respective Cache Page Descriptor(CPD). The CPDs are also replicated with the cache pages. Each CPDspecifies a back-reference to the RPD that most recently mapped it.

Data Structures for Supporting Distributed Raid with NVRAM Cache UsingRdma

FIG. 3 is a diagram that schematically illustrates data structures usedin computing system 20, in accordance with an embodiment of the presentinvention. In the present example, the data structures shown in FIG. 3reside in the memories of storage controllers 36. The data structuresare replicated in the two storage controllers C1 and C2 for resilience.The data structures are accessible to agents 40 using RDMA. Thus, agents40 are able to read and/or modify the data structures of FIG. 3 withoutrunning code on the CPUs of the storage controllers. In otherembodiments, the data structures may be sharded and replicated onmultiple servers, e.g., on servers 24. A given agent 40 on a givenserver 24 may cache relevant parts of the data structures locally forfast access.

The configuration of FIG. 3 shows three major data structures—a RAIDPage Descriptor Table (RPDT), a RAID Stripe Descriptor Table (RSDT), anda RAID Stripe Descriptor Page Table (RSD_PT). The description thatfollows assumes that the entire RBA space is managed using a single setof such data structures. When the RBA space is divided into chunks, asdescribed above, a separate configuration of data structures is used perchunk.

In an embodiment, the RPDT is implemented as a flat table, which liststhe RPDs of all the RAID pages that are currently stored in system 20.Each RPD (i.e., each entry of the RPDT) comprises the following datafields:

-   -   “Present bit”—A bit that specifies whether the RAID page is        cached in NVRAM cache 46 or stored on storage devices 28. In the        present example, a present bit value of “1” (set) indicates that        the RAID page is present in NVRAM cache 46. A present bit value        of “0” (not set) indicates that the RAID page is stored on        storage devices 28.    -   When the present bit is set—Location of the RAID page in the        NVRAM cache. The location is specified using a server ID (e.g.,        16 bits), a cached block ID (e.g., 10 bits), and possibly some        reserved bits (e.g., 0-5 or 0-37 bits).    -   When the present bit is not set—Location of the RAID page on the        storage devices. The location is specified using a        storage-device ID (e.g., 5 bits) indicating the storage device        on which the RAID page is stored, a Logical Block Address (LBA,        e.g., 18 or 28 bits) indicating the LBA used for storing the        RAID page on that storage device, a RAID stripe ID (e.g., 18 or        28 bits), and possibly some reserved bits (e.g., 2 bits).

In an embodiment, the LBA field in the RPD is optional, since thisinformation is also available in the RSD, to be described below.Omitting the LBA from the RPD, however, typically incurs two round-tripaccesses for obtaining the LBA. Moreover, the RSD may be paged-out to astorage device, which would slow down the process even further. Sinceonly reads are affected by this degradation, this implementation may befeasible in some embodiments.

The sizes of the data fields in the example above correspond to a systemhaving twenty-four storage devices 28, by way of example. The sizes ofthe LBA and stripe-ID fields typically depend on the size of the RBAspace or of the chunk in question. Thus, to reduce in-memory metadatasize, multiple relatively small RAID chunks may be beneficial. Forexample, the system could use 13 bits for addressing in 32 MB chunks,thus fitting an RPD into a 32-bit value, or 1-2 TB, fitting the RPD intoa 64-bit value.

In an embodiment, the RSDT is implemented as a flat table, which liststhe RAID Stripe Descriptors (RSDs) of all the RAID stripes that arecurrently managed by system 20. Each RSD (i.e., each entry of the RSDT)comprises multiple RSD Entries (RSDEs), each specifying a respectiveblock (data or parity block) in the stripe.

In the present example, the RSDE of each block has 32-64 bits andcomprises the following data fields:

-   -   RPDT index (e.g., 13 or 28 bits), indicating the RPDT entry that        stores the RPD of the RAID page stored in the block.    -   Storage device ID (e.g., 5 bits), indicating the storage device        on which the block is stored.    -   LBA (e.g., 13 or 28 bits), indicating the LBA used for storing        the block on the storage device.

The RSD in the present example has the following data fields:

-   -   N RSDEs, for the N respective data blocks in the stripe.    -   C RPDs, for the C respective parity blocks in the stripe.    -   RAID stripe width (holds the value of N, in log(N,2) bits).

The RSD_PT is an optional data structure, which enables paging-out theRSDT or parts thereof to storage devices 28, instead of holding theentire RSDT in the memory of storage controllers 36. When used, eachentry of the RSD_PT addresses a section of the RSDT. The section size istypically a system parameter. In an embodiment, the RSD_PT isimplemented as an array of bits, with each bit specifying whether thecorresponding section of the RSDT is present in NVRAM or paged-out tostorage devices 28. In such an implementation, the paged-out location ofthe RSD can be inferred from the bit location (e.g., offset).

Agents 40 may access the RSD_PT using RDMA, so as to identify whether asection of the RSDT has been paged-out, and if so, to obtain the storagelocation of this section on storage devices 28. Using this information,agents 40 may then access the paged-out section on the storage devices.

In a typical embodiment, the RPDT and RSD_PT are stored in-memory, e.g.,in an NVRAM of the storage controllers. The RSDT is typically split—SomeRSDs are stored in-memory at the storage controllers, and other RSDs arepaged-out to storage devices 28.

In some embodiments, system 20 maintains a “server-specificpotentially-dirty list” per server 24. The server-specificpotentially-dirty list of a server lists the RPD IDs of the RAID pageswritten by this server. The server-specific potentially-dirty lists aretypically stored in a mirrored configuration on both storage controllers36. These lists are used, for example, for recovering from a “writehole” scenario in which a server crashes during an operation. Inalternative embodiments, the system may use transaction logs instead ofpotentially-dirty lists.

The data structure arrangement described above and depicted in FIG. 3 ischosen purely for the sake of conceptual clarity. In alternativeembodiments, the disclosed techniques can be implemented using any othersuitable arrangement of data structures.

Example I/O Operations

The description that follows describes several processes that arecarried out by servers 24 using the disclosed distributed RAID and NVRAMcache schemes. The processes below include, for example, writing data toa stripe, reading data from a stripe, destaging stripes from NVRAM cacheto persistent storage, rebuilding a stripe following failure of astorage device, redistributing data as part of addition or removal of astorage device, and garbage collection.

As will be shown below, these processes are carried out by the serversalone, without having to execute code on the storage controllers.Moreover, even though the user volumes may be shared among multipleservers, the processes described below do not involve any communicationbetween the servers, and do not require the servers to obtain locks onthe data items being written.

In some embodiments, the disclosed processes use the RDMA atomic Compareand Swap (CAS) primitive to write data while protecting from collisionsbetween multiple servers that attempt to write to the same block orstripe. The CAS command typically specifies an address, new data to bewritten to that address, and a test value. The storage device testswhether the data currently stored in the address is equal to the testvalue, and writes the new data only if the test is successful. The testand subsequent write are performed by the storage device atomically,i.e., without allowing any intervening writes to the address inquestion.

In some embodiments, agent 40 uses the RAID atomic CAS command only whenneeded, e.g., only when the user volume is actually shared with at leastone other server. If the volume is not shared, agent 40 may carry outthe disclosed processes while replacing the RAID atomic CAS commandswith normal write commands. This optimization is desirable, since theCAS command is considerably more expensive in terms of computations andlatency than the normal write command. A given agent 40 may use variousways to determine whether a user volume is shared with another server ornot. For example, in an embodiment, user volume layer 52 may hint RAIDlayer 48 whether the user volume is mapped by any server other than thecurrent server. Care should be taken, however, to ensure that no otherprocess, e.g., a background process such as garbage collection, writesto the volume in question.

Write Operation

FIG. 4 is a flow chart that schematically illustrates a method forperforming a write command, in accordance with an embodiment of thepresent invention. Such a method is typically carried out by agent 40 ineach server 24. The description below refers to a single data page, forthe sake of clarity. When storing multiple data pages, the process ofFIG. 4 is typically repeated per data page, possibly at least partiallyin parallel.

The method begins with RAID layer 48 in agent 40 of a given server 24receiving a data page for storage at a certain RBA, at a page input step80. At an allocation step 84, agent 40 allocates an NVRAM cache page inNVRAM cache 46 from the pool of free NVRAM cache pages.

At a writing step 88, agent 40 writes the data page by performing threeoperations, typically in parallel: Agent 40 reads (using RDMA) the RPDof the RBA of the data page from the RPDT; writes the data page (usingRDMA) to the allocated NVRAM cache page (typically to two redundantNVRAM cache pages on different failure domains); and writes the RPD ID(using RDMA) to the server-specific potentially-dirty list.

At an RPD updating step 92, agent 40 updates the RPD of the data page inthe RPDT using RDMA atomic CAS. The RPD is typically updated in bothstorage controllers, with a certain fixed ordering. The test value inthe CAS command is the RPD that was read from the RPDT at step 88 above.

At a CAS checking step 96, agent 40 checks whether the atomic CAScommand of step 92 was successful or not. A failure of the CAS commandmeans that the RPD of the data page has changed between step 88 and step92. In such a case, agent 40 concludes that some other server 24 hasmodified the data page and updated the RPD. Therefore, to avoidinconsistency, agent 40 discards the write operation, at a discardingstep 100, and acknowledges the write command, at an acknowledgement step104. Otherwise, i.e., if the CAS command completed successfully, agent40 proceeds to acknowledge the write command at acknowledgement step104, without discarding.

In the example above, agent 40 used the atomic CAS command to ensurethat the data page in question is not modified by some other interveningwrite command by another server. Such a scenario is possible only if theuser volume in question is shared between two or more servers. As notedabove, if agent 40 can guarantee that the user volume is not shared,step 92 can be carried out using a normal write command instead of CAS,and steps 96 and 100 can be omitted.

Destage Operation

In some embodiments, a predefined number of stripes (possibly a singlestripe but typically several stripes) is defined in system 20 as a“destage unit.” Each agent 40 accumulates data pages in NVRAM cache 46,e.g., using the method of FIG. 4 above, until an entire destage unit hasbeen accumulated. Only at this point, agent 40 calculates the parity forthe stripes of the destage unit, allocates storage space for the stripeson the storage devices 28, and transfers the full stripes to the storagedevices.

FIG. 5 is a flow chart that schematically illustrates a method fordestaging RAID stripes from NVRAM cache 46 to storage devices 28, inaccordance with an embodiment of the present invention. Such a method istypically carried out by agent 40 is each server 24.

The method begins with agent 40 detecting that an entire destage unithas been accumulated by the server in NVRAM cache 46, at a destagetriggering step 110. In some embodiments, before triggering a destageoperation, agent 40 removes from NVRAM cache 46 pages that hold staledata, i.e., pages that are not pointed to by the RPD because they wereoverwritten. The RPD can be found from the Cache Page Descriptor (CPD).After removing the stale NVRAM cache pages, agent 40 checks againwhether a destage unit is full, and if so, proceeds with the destageoperation.

Agent 40 calculates the parity pages for the various stripes in thedestage unit, at a parity calculation step 114. At a storage pageallocation step 118, agent 40 allocates physical pages on storagedevices 28 for the data pages and parity pages of the destage unit.Agent 40 typically holds a pool of free physical pages for this purpose,and obtains additional free physical pages from the storage controllersas needed.

At an RSD allocation step 122, agent 40 allocates RAID StripeDescriptors (RSDs) for the stripes of the destage unit. Agent 40typically holds a pool of RSD allocations for this purpose, and obtainsadditional RSD allocations from the storage controllers as needed.

Then, at a destaging step 126, agent 40 transfers the full stripes(including data and parity pages) from NVRAM cache 46 to storage devices28. Agent 40 performs three operations, typically in parallel: Agent 40writes the data pages and parity pages to the allocated physical pageson storage devices 28; writes the appropriate data fields in theallocated RSDs (using RDMA write); and writes the RPD IDs to thepotentially-dirty list of the server (using RDMA write). At a destagechecking step 130, agent 40 waits until all the write and RDMA-writeoperations of step 126 are completed.

Then, at an RPD updating step 134, agent 40 updates the RPDs of all thedata and parity pages in the RPDT using RDMA atomic CAS. The RPDs aretypically updated on both storage controllers 36, in consistent order.As explained above, the RPD of each (data or parity) page points to theRSD of the stripe to which the page belongs.

At a CAS verification step 138, agent 40 checks whether the CAS atomicwrites of step 134 were all successful. If successful, agent 40considers the destage operation completed, at a destage completion step142.

Otherwise, if one or more of the CAS atomic writes of step 134 havefailed, agent 40 concludes that the RPDs of one or more pages in thedestage unit have changed between step 134 and step 138, because anotherserver 24 has modified the data and updated the RPDs. Agent 40 thereforeaborts the destage operation, at a destage aborting step 146. In orderto return to the state prior to destaging, agent 40 returns the valuesof the PRDs to their previous values using CAS atomic write. The methodmay then loop back to step 110, in which agent 40 cleans-up stale NVRAMcache pages and waits for a destage unit to fill up.

As explained above with regard to the write operation, in someembodiments agent 40 updates the RPDs using normal RDMA write instead ofRDMA atomic CAS, if it is guaranteed that the user volume is not sharedwith any other server. In this case, step 138 is omitted.

In some embodiments, agent 40 retains on server 24 local copies of thedata pages of the destage unit, in order to calculate the parity pagesat step 114. In an alternative embodiment, agent 40 may avoid the needto retain such local copies, by calculating the parity progressively, asthe stripes gradually fill up.

In this embodiment, agent 40 retains C interim parity pages for thestripe that is currently being accumulated. When adding a new data pageto the stripe, agent 40 updates the interim parity pages to account forthe new data page. When the stripe becomes full, the interim paritypages becomes valid parity pages.

If an RPD becomes invalid during accumulation of the interim parity(e.g., because another server writes to the same stripe), agent 40 needsto revert to RDMA read the data pages in order to calculate the paritycorrectly. Old data pages should be read in case there are less invalidRPDs than valid RPDs, and new pages should be read otherwise.

Partial Destage Operation

When carrying out the destage operation of FIG. 5 above, an underlyingassumption is that the garbage collection process is sufficiently fast.If the garbage collection process is slow, agent 40 will have difficultyin filling-up an entire destage unit. The destage process may bedelayed, and in turn slow the entire storage process to the rate ofgarbage collection. Moreover, in some embodiments, e.g., when usingFlash-based storage devices, the garbage collection process may bedetrimental to performance and storage-device endurance, due to itsinherent write amplification.

One possible solution to these problems is for agent 40 to revert to a“partial destaging” process. In this process, instead of destaging fullstripes, agent 40 is allowed to destage partially-filled stripes to thestorage devices, by looking-up and filling stripes with pre-existingholes (stale NVRAM cache pages), such that new data is placed instead ofthe holes, albeit updating the stripe parities. Agent 40 would typicallyprefer to add new data pages to emptier stripes, in order to reducewrite and read amplification.

FIG. 6 is a flow chart that schematically illustrates a method forpartial destaging of a RAID stripe, in accordance with an embodiment ofthe present invention. Such a method is typically carried out by agent40 is each server 24.

The method begins with agent 40 selecting the emptiest known stripe onstorage devices 28, at a stripe selection step 150. In an exampleembodiment, agent 40 records the indices of the emptiest RSDs it hasencountered in previous write operations. In another embodiment, agent40 may crawl the RSDT to find the emptiest stripe, or identify theemptiest stripe in any other suitable way. The number of free pages inthis stripe is referred to as “free_slots”.

At a stripe readout step 154, agent 40 reads from the selected stripe(i) the parity pages, and (ii) min(free_slots, N-free_slots) data pages.At a new parity calculation step 158, agent 40 calculates new paritypages for the stripe, based on the existing parity pages and the nextfree_slots data pages that are pending for destaging in NVRAM cache 46.

At a physical page allocation step 162, agent 40 allocates physicalpages on storage devices 28 for the data pages and parity pages of thestripe. As explained above, the physical pages are typically allocatedfrom a pool of free physical pages held by agent 40. At a new RSDallocation step 166, agent 40 allocates a new RSD for the stripe fromthe pool of RSD allocations.

At a partial destaging step 170, agent 40 writes the data and paritypages of the stripe to storage devices 28. Agent 40 performs threeoperations, typically in parallel: Agent 40 writes the data pages andparity pages to the allocated physical pages on storage devices 28;writes the appropriate data fields in the allocated RSD (using RDMAwrite); and writes the RPD IDs to the potentially-dirty list of theserver (using RDMA write).

At steps 162-170, the data and parity pages are not updated in-place,but rather to new physical pages and to a newly allocated RSD. Such newallocations are needed to avoid collision with a degraded read(described below) that accesses the same stripe.

At a partial destage checking step 174, agent 40 waits until all thewrite and RDMA-write operations of step 170 are completed. At an RPDupdating step 178, agent 40 updates the RPDs of the data and paritypages in the RPDT using RDMA atomic CAS. The RPDs are typically updatedon both storage controllers 36, in consistent order. The RPD of each(data or parity) page points to the new RSD of the stripe.

As in the full-destage process of FIG. 5, agent 40 now verifies that allRDMA atomic CAS operations were successful to avoid collision withanother server. If collision is detected, an aborting procedure similarto step 146 of FIG. 5 is performed.

At a releasing step 182, after a certain timeout, agent 40 returns theprevious RSD and data and parity pages to the server-specific pools. Thetimeout is typically needed to ensure that no other server needs the RSDand pages for performing a degraded read.

In various embodiments, agent 40 may use various criteria to decide whento wait for additional pages and when to trigger partial destaging. Inone embodiment, agent 40 begins partial destaging as soon as the numberof pending data pages is sufficient for filling the emptiest knownstripe. In alternative embodiments, agent 40 continues to wait beyondthis point, attempting to detect an even emptier stripe.

Read operation

FIG. 7 is a flow chart that schematically illustrates a method forperforming a read command, in accordance with an embodiment of thepresent invention. Such a method is typically carried out by agent 40 ineach server 24. The description below refers to a single data page, forthe sake of clarity. When reading multiple data pages, the process ofFIG. 7 is typically repeated per data page, possibly at least partiallyin parallel.

The method begins with agent 40 reading the RPD of the data page (usingRDMA read), at an RPD readout step 190. At a location checking step 194,agent checks the “Present bit” in the RPD, to determine whether the datapage is cached in NVRAM cache 46 or stored on storage devices 28.

If the data page is cached in NVRAM cache 46, agent 40 reads the datapage from the NVRAM cache (using RDMA read), at a cache readout step198. Following readout of the data page, agent 40 reads the RPD again(using RDMA read). If the data page is stored on storage devices 28,agent 40 reads the data page from the storage devices, at a storagereadout step 202. Following readout of the data page, agent 40 reads theRPD again (using RDMA read).

At an RPD checking step 206, agent 40 checks whether the RPD read atstep 198 or 202 differs from the RPD read at step 190. If the RPD haschanged, agent 40 concludes that a collision has occurred and the methodloop back to step 190 for retrying the readout operation. Otherwise,agent 40 provides the data page as output, at an output step 210, andthe method terminates.

As explained above, in some embodiments agent 40 uses the NVRAM cache asa read cache, as well. In these embodiments, agent 40 adds the followingoperations to step 202.

-   -   Allocate a read-cache page in NVRAM cache 46.    -   Read the data page from storage devices 28 and save a copy in        the allocated read-cache page in NVRAM cache 46.    -   Update the RPD of the data page using RDMA atomic

CAS. In the updated RPD, the “Present bit” is set (indicating that thepage is present in the NVRAM cache), and the RPD points to theread-cache page in NVRAM cache 46 in which the copy of the data page issaved.

Degraded Read Operation

The term “degraded read” refers to a process of reconstructing a datapage from the other data and parity pages in the stripe. This process iscarried out, for example, when agent 40 attempts to read a data pagefrom a storage device, but finds that the storage device is unavailable.Degraded read is relevant to stripes that have been destaged to storagedevices 28.

Consider a scenario in which, at step 202 of FIG. 7, agent 40 fails toread the data page from the storage device. In response to the failure,in an embodiment, agent 40 carries out the following operations:

-   -   Read the RSD of the stripe to which the data page belongs. The        RSD is typically read by:        -   i. Reading the relevant RSD_PT bit using RDMA read,            according to the stripe ID found in the RPD obtained at step            190.        -   ii. If, according to the RSD_PT bit, the RSD is present in            the NVRAM cache, read the RSD from the NVRAM cache using            RDMA read. Otherwise, read the RSD from storage devices 28.    -   Read all the data and parity pages from the stripe that are        needed for recovering the requested data page.    -   Read the RPD of the requested data page again, using RDMA read.        If the RPD has changed since step 190, restart the entire read        process, from step 190.    -   Otherwise, calculate the requested data page from the other data        and parity pages in the stripe, and provide the reconstructed        data page as output.    -   Optionally, allocate a write-cache page in NVRAM cache 46, write        the reconstructed data page to this write-cache page using RDMA        write, and update the RPD of the data page using RDMA atomic        CAS.

Stripe Re-Distribution Operation

In some embodiments, a storage controller 36 or a given agent 40 carriesout a stripe re-distribution process, which re-distributes the pages ofa RAID stripe over a larger or smaller number of storage devices 28. Thedescription that follows refers to “a processor” that performsre-distribution. This processor may comprise, for example, the CPU of astorage controller 36 or of a server 24. When performed by a storagecontroller, the process is typically mirrored to the peer storagecontroller.

Re-distribution is typically performed upon addition or removal of astorage device 28. In contrast to rebuild processes, to be describedbelow, stripe re-distribution is performed with advance information thata storage device is to be added or removed.

In an example embodiment, when a new storage device 28 is added tosystem 20, the processor may save storage space by rebuilding existingstripes, so as to form wider stripes (using a modified RAID scheme thatuses a larger number of pages per stripe). As noted above, the RSD ofeach stripe comprises a stripe width field, thus supporting thepossibility to define a different stripe width per stripe.

In the redistribution process, the processor typically reads existingstripes into NVRAM cache 46 while atomically updating the RPDs of theirpages, and then adding these pages to existing stripes. In anembodiment, as long as there are non-redistributed stripes in the RSDT,the processor performs the following:

-   -   Select a stripe for re-distribution from the RSDT. This stripe        is referred to as a source stripe.    -   Move the selected stripe to NVRAM cache 46 (e.g., using read        operations such as described in FIG. 7).    -   For each page in the source stripe, select a respective stripe        from the RSDT. These stripes are referred to as destination        stripes.    -   For each destination stripe, move the destination stripe to        NVRAM cache 46, add the corresponding page from the source        stripe to the destination stripe, and destage the (now wider)        destination stripe to storage devices 28. As part of the        destaging process, update the RSD of each destination stripe to        reflect the new (larger) stripe width. There is no need to        overwrite the pages in the destination stripe that did not        change. Then, after a time-out, perform garbage collection on        the released parity pages and RSD.

In an embodiment, if the processor cannot find a sufficient number ofdestination stripes, the processor may either retain the last sourcestripe in NVRAM, or refrain from re-distributing the last source stripe.The above process is depicted purely by way of example, and any othersuitable re-distribution process may be used. For example, the processormay re-distribute stripes over multiple new storage devices at the sametime, incurring only a single re-distribution operation with only asingle parity calculation and rewrite per stripe.

In an embodiment, when a storage device 28 is about to be removed fromsystem 20, the processor may re-distribute the stripes in which thatstorage device takes part over the remaining number of storage devices.In this embodiment, the processor reduces the tripe width from N to N−1by performing the following:

-   -   Select N−1 source stripes from the RSDT.    -   For each source stripe:        -   Identify in the source stripe the page that is stored on the            storage device to be removed. Copy the identified page to            NVRAM cache 46, including updating the RPD of the page using            CAS to point to the NVRAM cache.        -   Read the existing parities of the source stripe, and            calculate new parities (excluding the page that is stored on            the storage device to be removed).        -   Allocate two new pages on the storage devices of the new            parities, and destage the parities to the new locations.        -   Allocate and write new RSD, indicating the new RAID scheme            with the smaller stripe width.        -   RDMA write the RPD ID to the server-specific            potentially-dirty RPD list.        -   Update all RPDs using CAS. In case of CAS failure            (indicative of collision), abort the transaction (including            reverting to previous RPDs using CAS) and retry.    -   Destage a new stripe comprising the N−1 pages, which belonged to        the N−1 respective source stripes and reside on the storage        device to be removed.    -   After a time-out, perform garbage collection on the released        parity locations and RSDs.

In an embodiment, if the processor cannot find N−1 source stripes tore-distribute, the processor may perform the above process for a smallernumber of source stripes, and either retain the resulting pages in theNVRAM cache or destage them in a partial stripe. The above process isdepicted purely by way of example, and any other suitablere-distribution process may be used. For example, the processor mayperform a single re-distribution process that reduces the stripe widthfrom N to M, for any desired N>M>0.

Stripe Rebuilding Operation

In some embodiments, a storage controller 36 or a given agent 40 carriesout a stripe rebuilding process, which reconstructs RAID stripesfollowing uncoordinated unavailability (e.g., failure or uncoordinatedremoval) of a storage device 28. The description that follows refers to“a processor” that performs rebuilding. This processor may comprise, forexample, the CPU of a storage controller 36 or of a server 24. Whenperformed by a storage controller, the process is typically mirrored tothe peer storage controller.

In some embodiments, the processor recalculates the pages that residedon the unavailable storage device from the remaining data and paritypages of the respective stripes. The recalculation may be performedusing the “degraded read” process described above. The recalculatedpages may then be destaged to one or more functional storage devices.

In some cases, however, it is desirable to reconstruct and store thedata that resided on the unavailable storage device as quickly aspossible, before compacting the existing stripes into a new (narrower)RAID scheme. This sort of rebuilding shortens the time duration in whichthe system (and possibly some applications) operate with degradedperformance, at the expense of prolonging the duration of time in whichthe system operates with reduced redundancy.

In such embodiments, the processor performs the following two phases:

Phase 1:

-   -   Select N−1 stripes from the RSDT, in which the missing page is        not a parity page.    -   For each selected stripe, recalculate the missing page using        “degraded read” into NVRAM cache 46 (including updating the RPD        of the page using CAS to point to the NVRAM cache).    -   Destage the N−1 recalculated pages in a new stripe of width N−1.

Phase 2:

-   -   Select N−1 stripes from the RSDT.    -   For each selected stripe:        -   Read the degraded page.        -   Read the existing parity pages (that were calculated            including the page stored on the unavailable storage device)            and calculate new parity pages (excluding the page stored on            the unavailable storage device).        -   Allocate two new pages on the storage devices of the new            parity pages.        -   Destage new parity pages to the new locations.        -   Allocate and write new RSD, indicating the new RAID scheme            having a stripe width of N−1.        -   RDMA write the RPD ID to the server-specific            potentially-dirty RPD list.        -   Update all RPDs using CAS.        -   In case of CAS failure (indicative of collision), abort the            transaction (including reverting to the previous RPDs using            CAS) and retry.

Following Phase 2, after a time-out, the processor typically performsgarbage collection on the released parity locations and RSDs.

In an embodiment, the processor may avoid the “degraded read” at thebeginning of Phase 2 by reading the missing data pages directly, usingthe RPDs created for these pages in Phase 1. This technique requiresadditional metadata for ensuring that the RPD was not overwritten sinceit was written in Phase 1. In an example implementation, the processormay store a respective index in the RSDT for each such RPD whileperforming Phase 1. These indices can then be used during Phase 2 toverify the RPDs. Volatile storage may be used for storing this temporarydata structure.

The example re-distribution and rebuilding processes described above aredepicted purely for the sake of conceptual clarity. In alternativeembodiments, any other suitable process can be used. In someembodiments, the disclosed re-distribution and/or rebuilding processescan be combined with the garbage collection process, thereby increasingefficiency. In other embodiments, re-distribution and rebuilding arecarried out separately from garbage collection.

Recovery from Server Failure (“Write Hole”)

In some embodiments, storage controllers 36 recover from “write hole”scenarios in which a certain server 24 fails during a write operation.One major “write hole” scenario, although not the only scenario, occurswhen a server fails between RPD CAS updates. A server 24 that failsafter performing some of the CAS operations leaves the data structuresof system 20 in an inconsistent state. Since a server typicallytransfers all CAS operations to the RDMA NIC in parallel, this scenariois highly unlikely. A scenario of a server failing after sending the CASoperations, but before detecting that one or more of the CAS operationshas failed, is more likely. In any of these scenarios, some of the RPDsare left pointing to resident caches and a non-full stripe on thestorage devices which will later be garbage collected (using thepotentially-dirty RPD list).

Typically, storage controllers 36 are responsible for destaging pages ofa failed server that are cached in NVRAM cache 46, and for releasing anyother remaining resources. Storage controllers 36 are also responsiblefor scrubbing the two copies of all NVRAM data structures to resolveinconsistencies. Servers 24 may assist the storage controllers inperforming this process by writing cyclic hint logs containing theentries that are not confirmed to be consistently written in two copies.

Garbage Collection and Compaction

In some embodiments, storage controllers 36 carry out garbage collectionprocesses and/or other background tasks. In some embodiments these tasksare distributed to servers 24. The description that follows refers to “aprocessor” that performs these tasks. This processor may comprise, forexample, the CPU of a storage controller 36 or of a server 24.

In an embodiment, the processor performs garbage collection for obsoletedata pages on storage devices 28. As described above, write commandsthat update RPDs that already reside on the storage devices areinitially cached in NVRAM cache 46, and later destaged to new storagelocations on the storage devices. The previous, invalid versions ofthese pages should be identified and discarded, and their storagelocations released for storing new data.

In some embodiments, the processor performs this garbage collectionprocess by identifying mismatches between the RSDT and the RPDT (seeFIG. 3). As explained above, each RPD in the RPDT specifies the storagelocation of the data page, and each RSD in the RSDT specifies the RPDsand storage locations of the pages in the stripe. If, for a certain RPDID, the RPDT and the RSDT specify different storage locations, then thestorage device page specified in the RSDT is invalid and should begarbage-collected. In some embodiments, the processor crawls orotherwise searches the RSDT for such mismatches. In some embodiments,agents 40 may provide the processor hints that improve the efficiency ofthe garbage collection process. One such hinting mechanism is theserver-specific potentially-dirty list described above.

In some embodiments, during or following the garbage collection process,the processor compacts the stripes in which invalid pages have beendiscarded. The compaction process is similar to the re-distributionprocess described above—The processor reads incomplete stripes to NVRAMcache 46, and writes the data pages into other incomplete stripes. In anembodiment, the processor prefers to compact stripes with the largestnumber of invalid pages.

In some embodiments, the processor performs garbage collection andcompaction on multiple stripes simultaneously in order to reduce theamount of actual data movement. Nevertheless, whenever data is added toa stripe, the parity pages are recalculated and written to a newlocation, allowing degraded read operations to complete successfully.

Consider, for example, a RAID-6 scheme in which each stripe has eightdata pages and two parity pages. Consider the following three stripes(in which d denotes data pages, p and q denote parity pages, and Xdenotes an invalid page):

When performing garbage collection and compaction on multiple stripessimultaneously, the processor is able to compact these three stripesinto the following single stripe without any data movement:

The parity pages p and q of the newly-created stripe are recalculatedover the data pages collected from the three incomplete stripes.

In some embodiments the processor prefers to write combined stripes tonew locations, so that the underlying storage media performs sequentialwrites rather than random writes.

In some embodiments, the processor releases RSDs as part of the garbagecollection process. To allow for RSDT paging, allocated RSDs aretypically compacted together. The processor typically moves an RSD byfirst copying the RSD, and then updating all the RPDs pointing to theRSD using CAS. Alternatively, the processor may employ another level ofindirection, which is not pageable and indexes the RSDT per stripe. Inthis solution, moving an RSD can be performed by a single RDMA writeoperation of such an index.

In some embodiments, as part of the garbage collection process, theprocessor allocates and periodically sends to servers 24 lists of (i)available free RSDs and (ii) available free storage pages (preferablycontiguous) on storage devices 28.

Paging-Out of RSDT

In some embodiments, storage controllers 36 may page-out parts of theRSDT from memory to storage devices 28. If paging is enabled, the RSDTitself it typically over-provisioned to allow for simpler and moreefficient garbage collection. In some embodiments, the processor maypage-out the RSDT to an area in the RBA address space in which a simplerRAID scheme is used (e.g., mirroring as opposed to RAID-6 exposed to theuser volume layer). In other embodiments, the processor may page-out theRSDT using the same RAID scheme used for user volumes, to an area of theRBA address space for which the relevant RSDs cannot be paged out. Thepaging granularity should typically be the stripe width of theunderlying RAID scheme or some integer multiple thereof.

Optimizations for Large Write-Command Sizes

In some embodiments, system 20 supports write commands (“I/Os”) havingmultiple possible sizes simultaneously. For example, some workloads mayuse 4KB write commands (i.e., write data pages of 4 KB size), whereasother workloads may use 32 KB write commands (i.e., write data pages of32 KB size). Other page sizes are also possible.

In one embodiment, storage controllers 36 create multiple RAID areaswith different block sizes, such that the layers above (e.g., uservolume layer 52 and volume map 60) allocate volumes in the differentRAID areas based on configuration or per-I/O, depending on I/O size. Thelatter scheme typically requires address virtualization at the volumemap level, and may increase fragmentation at that level.

In an alternative embodiment, the storage controllers may group multipleRPDs into larger “compound RPDs.” For example, multiple 4 KB RPDs can begrouped and stored as 32 KB compound RPD. The sizes of the RPDs andcompound RPDs are given purely by way of example. Moreover, the systemmay use two or more sizes of compound RPD concurrently.

Let CP denote the size of a compound page (32 KB in the presentexample). A compound RPD is defined as a collection of RPDs starting atan address aligned to CP and containing multiple RPDs (eight 4 KB RPDsin the present example). When a write of size CP (or larger) arrives,the storage process is the same as for a small block write, except thata CP size page is allocated in the server-specific NVRAM cache area foreach such write. Instead of updating a single RPD using CAS, all theRPDs in the compound page are updated using CAS, while also marking themas compound. If several compound page sizes are supported, then thismarker should also specify the compound page size. Destaging of compoundpages is similar to destaging of individual pages, with the exceptionthat the RSD should also be marked appropriately—effectively creating astripe with CP-size blocks. A buddy allocator may be used for NVRAMcache pages of different sizes.

In an alternative embodiment, compound RPDs may be implemented by addinga second level of indirection, creating a page-table hierarchy of RPDs.For example, 32 KB page descriptors can be used in the first level and 4KB pages in the second level. This solution reduces the number of CASoperations, at the expense of larger memory usage and an added roundtripdelay.

Mitigating Double Network Traffic on Write

Consider an embodiment of system 20 in which storage devices 28 areconnected directly to the two storage controllers 36, e.g., by apoint-to-point connection or a fast private network. The two storagecontrollers nevertheless form two different failure domains. In theproposed design, every written page needs to be first written using RDMAto two NVRAM cache locations in two different failure domains, therebydoubling the server's network bandwidth and I/O rate for write commands.

One possible way to reduce the server bandwidth and I/O rate is to writethe page to a single copy in a single NVRAM cache location, andadditionally back-up the page on a single storage device 28. The NVRAMstorage location and the storage device should be chosen in differentfailure domains.

Unless the page is overwritten before a stripe is available fordestaging, the initial storage location on the storage device will alsobe the final storage location, so as not to create excess writeamplification. The storage device is typically chosen according to theRSD slot for the write command.

Thin Provisioning and Over-Provisioning

The virtualization layer provided by the RPDT allows for a simpleimplementation of thin-provisioning at page granularity, since actualstorage space on storage devices 28 is only allocated when a stripe isdestaged. This implementation may come at the expense of increasing thesize of the RPDT to cover the entire thinly-provisioned virtualcapacity. This increase can be mitigated by implementingcoarse-granularity block thin-provisioning at the volume map level,combined with fine-granularity thin provisioning at the RPDT level.

In-Line Compression During NVRAM Caching and Storage

In some embodiments, system 20 compresses at least some of the datapages (also referred to as data blocks) before storage in order toincrease storage capacity. The description that follows illustratesseveral examples of using the NVRAM cache and redundant storageframework described above for storing compressed data. This sectiondescribes techniques and data structures used by agents in servers 24for in-line compression of the data being sent for caching and storage.Additionally or alternatively, compression may be applied in thebackground, to data that has already been stored, e.g., by storagecontrollers 36 and/or agents 40. Background compression is addressedfurther below.

Single Block Compression

FIG. 8 is a diagram that schematically illustrates data structures usedfor storing compressed data in system 20 of FIG. 1, in accordance withan embodiment of the present invention. In this embodiment, thestructures of the RPDT and of the NVRAM cache pages are adapted tosupport in-line compression by agents 40.

In this embodiment, agents 40 compress the RAID pages before cachingthem in stripes 47 of NVRAM cache 46. The compressed RAID pages arereferred to as Compressed Blocks (CBs). The right-hand-side of FIG. 8shows two NVRAM cache pages 220A and 220B having CPDs denoted CPD1 andCPD2, respectively. The NVRAM cache pages have a fixed size, e.g., 4 KB.The CBs may be of the same size or smaller than the NVRAM cache pages,and may be of different sizes.

Due to the compression, each NVRAM cache page is able to store more thanone CB, and possibly a non-integer number of CBs. A given CB may resideentirely in one NVRAM cache page, or it may be split between two pages.The present example shows four CBs denoted CB1 . . . CB4. CB3 begins inNVRAM cache page 220A and continues in NVRAM cache page 220B.

In addition to the CBs, each NVRAM cache page stores a metadata tablereferred to as Compressed Block Table (CBT). In the example of FIG. 8,NVRAM cache page 220A holds a CBT 224A, and NVRAM cache page 220B holdsa CBT 224B. Each CBT comprises one or more CBT entries (CBTEs). EachCBTE points to a respective CB and specifies (i) the RBA of the CB, and(ii) the offset (in bytes) in which the CB is located within the NVRAMcache page.

If a certain CB begins in one NVRAM cache page and ends in another, thelast CBTE of the former NVRAM cache page holds the ID of the latterNVRAM cache page. In this manner, agents 40 are able to easily find thecontinuation of the divided CB. Alternatively, the NVRAM cache pages ina given destage unit may be allocated continuously, in which case thereis no need for the last CBTE to point to the next NVRAM cache page.

In this embodiment, each RPD in the RPDT still points to a singlerespective RBA. Therefore, when a given NVRAM cache page may holdmultiple CBs, multiple RPDs may point to the same NVRAM cache page. Inthe example shown in FIG. 8, the first three RPDs in the RPDT(corresponding to CB1 . . . CB3) all point to NVRAM cache page 220A, andthe fourth RPD points to NVRAM cache page 220B.

In this embodiment, a certain agent 40 reads a RAID page from NVRAMcache 46 by performing the following:

-   -   Read the RPD of the desired RAID page from the RPDT, using RDMA.    -   Read the CBT of the NVRAM cache page that is pointed to by the        RPD, using RDMA.    -   Read the CB (the compressed data) that is pointed to by the        appropriate CBTE, using RDMA. The CB may need to be read from        two NVRAM cache pages.    -   Decompress the CB and return the decompressed data.

In some embodiments, agent 40 may read the CBT and the CB (thecompressed data) from an NVRAM cache page in a single read command. Thissort of readout reduces latency at the expense of higher networktraffic, assuming the entire CB is stored in the same NVRAM cache page.

In some cases, data of CBs or entire NVRAM cache pages may be modifiedin NVRAM cache 46 before it is destaged. If the data of an entire NVRAMcache page is modified, the overwritten NVRAM cache page may be simplydiscarded. If only part of the data in an NVRAM cache page is updated(e.g., one CB from among multiple CBs stored in the NVRAM cache page),the CBTEs of any obsolete CBs are marked as invalid, and the destagingprocess skips these CBs and does not destage them to storage devices 28.A destaging process of this sort is described further below.

Multi-Block Compression

In an alternative embodiment, an agent 40 may refrain from dividing alarge write command into blocks (e.g., 4 KB blocks), or divide it intosome multiple of the block size. Once the data of such a write commandis compressed, the resulting “compressed chunk” may span multiple NVRAMcache pages. In this embodiment, the RPD of any block in this chunk willpoint to the first NVRAM cache page holding the compressed chunk (eventhough the actual data of the block may be stored in some subsequentNVRAM cache page). Each CBTE in this embodiment specifies (i) the RBA ofthe block, (ii) the offset (in bytes) in which the compressed chunk islocated within the NVRAM cache page, and (iii) the offset (in blockunits) in which the block is located within the uncompressed chunk.

As in the previous embodiment, if a block is divided between two NVRAMcache pages, the last CBTE of the former NVRAM cache page specifies theID of the next NVRAM cache page. Alternatively, e.g., if NVRAM cachepages are allocated contiguously in NVRAM cache 46, this ID may not beneeded.

In this embodiment, a certain agent 40 reads a RAID page from NVRAMcache 46 by performing the following:

-   -   Read the RPD of the desired RAID page from the RPDT, using RDMA.    -   Read the CBT of the NVRAM cache page that is pointed to by the        RPD, using RDMA.    -   Read the compressed data using RDMA. The compressed data may        need to be read from several NVRAM cache pages.    -   Decompress the data.    -   Return the part of the decompressed data that corresponds to the        requested RAID page, according to the offset specified in the        CBTE.

In some cases it may be possible to decompress less than the entirecompressed chunk in order to reconstruct a desired block from within thechunk, e.g., if the underlying compression scheme supports randomaccess. In such cases the last three steps of the above readout processare more efficient.

Destaging of NVRAM Cache Pages Holding Compressed Data

In some embodiments, agents 40 destage NVRAM cache pages, which comprisecompressed data, to storage devices 28 using the method of FIG. 5 above.In these embodiments, the CBTs are destaged together with the respectiveNVRAM cache pages to which they belong. Destaging is typically performedusing RDMA, without triggering the storage controller CPU.

FIG. 9 is a diagram that schematically illustrates data structures usedfor destaging and storing compressed data, in accordance with analternative embodiment of the present invention. In this alternativeembodiment, the CBT is destaged as part of the RSDT, separately from theNVRAM cache pages.

In the example of FIG. 9, agent 40 has destaged a RAID stripe, whichcomprises the two NVRAM pages 220A and 220B shown in FIG. 8, to storagedevices 28. NVRAM cache page 220A has been destaged to a media block228A on one storage device 28, and NVRAM cache page 220B has beendestaged to a media block 228B on a different storage device 28. The RSDof the RAID stripe in question comprises two RSDEs 232A and 232B, whichpoint to media blocks 228A and 228B, respectively. In the presentexample, the RSD has also been destaged to storage devices 28. Thelocation of the RSD on the storage devices is specified in the RSD PT.

As can be seen in the figure, media blocks 228A and 228B hold thecompressed data (CB1 . . . CB4), but not CBTs 224A and CBT 224B thatoriginally resided in NVRAM cache pages 220A and 220B. Instead, CBTs224A and CBT 224B are stored in the respective RSDEs 232A and 232B,which are part of the RSD of the RAID stripe.

In these embodiments, in order to read a requested RAID page, agent 40performs the following:

-   -   Read the RPD of the desired RAID page from the RPDT, using RDMA.    -   Read the CBT that is pointed to by the RPD (using RDMA, or, if        the CBT has been destaged, from the RSDT or from another        location).    -   Read the CB (the compressed data) that is pointed to by the        appropriate CBTE, using RDMA. The CB may need to be read from        one or more media blocks.    -   Decompress the CB and return the decompressed data.

In yet other embodiments, agent 40 may destage the CBTs separately fromthe media blocks and separately from the RSDT or any other datastructure.

In the embodiment of FIG. 9 (in which the CBTs are destaged as part ofthe RSD and not of the media blocks), readout of a media block incurs anextra read operation from storage devices 28, in order to read the CBT.In these embodiments, it is not necessary to store the logical address(LBA) as part of the RPD, since this information also exists in the RSDthat is read anyhow. As a result, the RPD size can be reduced withlittle or no extra latency.

As explained above, in some embodiments storage controllers 36 may groupmultiple RPDs into larger “compound RPDs.” Typically, the compound RPDs(e.g., 32 KB in size) are compressed similarly to regular RPDs (e.g., 4KB in size), using large Compound-Page (CP) size cache pages, anddestaged accordingly.

Background Compression and Garbage Collection

Additionally or alternatively to the in-line compression schemesdescribed above, system 20 may compress the data that has been destagedto storage devices 28. Such background compression is typically appliedto large chunks of contiguous data that are “cold,” i.e., not modifiedfrequently. Background compression is typically performed by storagecontrollers 36, but may also be delegated, at least partially, to agents40 in servers 24. Background compression processes are typically givenlow priority, relative to latency-sensitive storage tasks, whencompeting for CPU resources.

Background compression may achieve high compression ratios because, forexample, it is can compress larger chunks of data (and can thereforebetter exploit spatial locality in the data) and has less latencyconstraints than in-line compression (and can therefore use more complexand powerful compression algorithms).

In some embodiments, storage controllers 36 may decide to applybackground compression selectively, e.g., to some user volumes but notto others. For example, the storage controllers may disable backgroundcompression for live volumes that are active and change frequently. Thestorage controllers may enable background compression for inactivevolumes, such as snapshots that are used for backing-up past versions ofuser volumes.

When media blocks are overwritten in compressed volumes, older versionof the data in the media blocks become invalid (“holes”). Since the datais compressed, the holes are often smaller than the media block size(e.g., holes smaller than 4 KB within a 4 KB media block). In someembodiments, storage controllers 36 run a compaction (“garbagecollection”) process that scans the metadata, discovers holes andrewrites compressed RPDs in order to remove holes.

RAID-Layer-Based Background Compression

In some embodiments, storage controllers 36 perform backgroundcompression exclusively within RAID layer 48, similarly to in-linecompression, possibly using larger chunks of data and a strongercompression algorithm. This approach may be used in some embodiments tocyclically rewrite entire volumes, while implicitly compacting holesthat are smaller than the block size.

In these embodiments, storage controller 36 compresses one or moreextents (or even an entire user volume) by performing, for each RBA:

-   -   I. Read RPD of RBA.    -   II. Read the data pointed to by the RPD. Compress the data into        the currently-written NVRAM cache page, similarly to inline        writing of new data.    -   III. Update the RPD using CAS, to point to the new location of        the compressed data in the NVRAM cache. If CAS fails, retry from        I.

The newly compressed blocks are destaged similarly to theinline-compression destaging scheme described above. If RBAs areallocated sequentially, the CBTE may be optimized to omit successiveRBAs.

RAID-Layer-Assisted, Extent-Based Background Compression

In some embodiments, system 20 represents user volumes in volume map 60of user-volume layer 52 using data structures referred to as volumetrees. The volume tree of a given user volume maps allocated logicaladdresses (in UBA space) onto physical addresses (in RBA space) in thestorage devices. Volume trees may be shared by multiple servers, andnodes in the volume trees may be shared by multiple user volumes, e.g.,due to volume cloning.

In some embodiments, the volume trees are reference-countedCopy-On-Write B-trees. B-trees are described, for example, by Rodeh, in“B-trees, Shadowing, and Clones,” ACM Transactions on Storage, volume 3,no. 4, February, 2008, and by Rodeh et al., in “BTRFS: The Linux B-TreeFilesystem,” ACM Transactions on Storage, volume 9, no. 3, August, 2013,which is incorporated herein by reference. Aspects relating to the useof shared volume trees in the context of the architecture of system 20are also addressed in U.S. patent application Ser. No. 14/697,653, citedabove.

In this representation, the leaves of the volume tree represent extents.The term “extent” means an allocated contiguous range of user addressesin the UBA address space. An extent typically comprises a pointer to ablock range. Each block (in RBA space) in the volume tree has areference count specifying the number of user extents (in UBA space)referencing it.

In some embodiments, storage controllers 36 perform backgroundcompression within at the volume-tree level, i.e., in volume layer 52,similarly to in-line compression. The background compression may uselarger chunks of data and a stronger compression algorithm. Thisapproach may also be used in some embodiments to cyclically rewriteentire volumes, thus creating large contiguous extents and implicitlycompacting holes that are smaller than the block size.

FIG. 10 is a flow chart that schematically illustrates a method forbackground compression at the volume-tree level, carried out by storagecontroller 36, in accordance with an embodiment of the presentinvention. The description below refers to compression of a singleextent, i.e., a single leaf node of a volume tree. Compression ofmultiple extents, e.g., an entire user volume, is typically carried outby repeating this process per extent.

The method begins with storage controller 36 marking the extent asclean, at a clean marking step 240. At a rewriting step 244, the storagecontroller reads the data of the extent from the appropriate RBAs onstorage devices 28, and rewrites the data in compressed form to newlyallocated RBAs on the storage devices.

At a dirty checking step 252, storage controller 36 checks whether theextent is marked dirty. If so, the storage controller concludes that anintervening write occurred since the extent was marked as clean at step240. In such a case, the storage controller aborts the method, at anaborting step 252.

If the extent is still marked as clean, the storage controller marks theextent as shared, and increments the reference count of the extent, anda reference incrementing step 256. This step ensures that a writecommand racing with the replacement of the old RBAs by the new RBAs willbe identified.

At a dirty re-checking step 260, storage controller checks again whetherthe extent is marked dirty. If so, the storage controller aborts themethod, at an aborting step 264. Steps 260 and 264 ensure that a writecommand racing with the marking of the extent as shared will beidentified and handled.

If the extent is still marked as clean, storage controller 36 atomicallyreplaces the original extent in the volume tree with one or more extentsthat are mapped to the new RBAs, at an extent replacement step 268. At areplacement success checking step 272, the storage controller checkswhether the atomic replacement of step 268 was successful.

If the atomic replacement has failed, the storage controller concludesthat the replacement operation has raced with a write and acopy-on-write. In this event, the storage controller decrements thereference count to its original value (before step 256) and aborts themethod, at a failure termination step 280. If the atomic replacement wassuccessful, the storage controller releases the old extent and the oldRBAs, at a releasing step 276, and the method terminates successfully.

When carrying out the method of FIG. 10, if RBAs are allocatedsequentially to the extent, the CBTE can be optimized by omittingsuccessive RBAs.

Extent-Based Background Compression

In some embodiments, storage controller 36 performs backgroundcompression of extents while exploiting the extent data structures.These techniques reduce the required RBA space, and thus reduce memoryutilization.

FIG. 11 is a flow chart that schematically illustrates a method forbackground compression at the volume-tree level, carried out by storagecontroller 36, in accordance with an alternative embodiment of thepresent invention. Again, the description below refers to compression ofa single extent. Compression of multiple extents, e.g., an entire uservolume, is typically carried out by repeating this process per extent.

The method of FIG. 11 begins with storage controller 36 marking theextent as clean, at a clean marking step 290. At a rewriting step 294,for each compressed chunk in the extent, the storage controller performsthe following:

-   -   Read the data of the chunk from the appropriate RBAs on storage        devices 28.    -   Compress the chunk into some temporary memory buffer.    -   When the buffer is sufficiently full, e.g., the buffer fill        level exceed some predefined threshold, write the compressed        data to newly allocated RBAs on the storage devices.

At an ECBT appending step 298, the storage controller writes an ExtentCBT (ECBT) at the end of the compressed extent (in RBA space). The ECBTtypically comprises a table that describes the location of eachcompressed chunk in the extent. Since the chunks are of constant size(before compression), each entry of the ECBT corresponds to a respectivechunk in the extent and specifies the length of the chunk (aftercompression).

At a dirty checking step 302, storage controller 36 checks whether theextent is marked dirty. If so, the storage controller aborts the method,at an aborting step 306. If the extent is still marked as clean, thestorage controller marks the extent as shared, and increments thereference count of the extent, and a reference incrementing step 310.

Storage controller 36 then atomically replaces the original extent inthe volume tree with one or more extents that are mapped to the newRBAs, at an extent replacement step 314. The storage controller marksthe extent as compressed and shared. At a replacement success checkingstep 318, the storage controller checks whether the atomic replacementof step 268 was successful.

If the atomic replacement has failed, the storage controller concludesthat the replacement operation has raced with a write and acopy-on-write. In this event, the storage controller decrements thereference count to its original value (before step 310) and aborts themethod, at a failure termination step 326. If the atomic replacement wassuccessful, the storage controller releases the old extent and the oldRBAs, at a releasing step 322, and the method terminates successfully.

The reference count updates and the dirty and clean marking and checkingare carried out to identify and avoid races, as described in the schemeof FIG. 10 above. Unlike the scheme of FIG. 10, however, the compressedextent in the scheme of FIG. 11 remains pseudo-shared as such an extentcannot support overwrites. In other words, in a conventional extent itis possible to overwrite blocks in-place (i.e., overwrite blocks). Suchoverwriting is not possible in a compressed extent, because theoverwritten compressed block may require more space than the spaceallocated to the previous compressed block

When using the scheme of FIG. 11, in order to read from an extent, anagent 40 reads the relevant entries of the ECBT, and then reads theappropriate compressed chunks, decompresses them and returns thedecompressed data. In some embodiments (e.g., for small extents), theentire extent may be read to reduce read latency.

In some embodiments, the ECBT may be stored in the extent data structureitself, thereby reducing readout latency at the expense of higher memoryutilization or more frequent extent paging.

In implementing the disclosed background compression schemes, careshould be taken when handling shared extents. Manipulation of sharedextents typically involves modifying various data structures such asvolume trees, and setting various references, backward references and/orreference counts. Compression schemes that are implemented exclusivelyin the RAID layer are agnostic to sharing of extents. Nevertheless, itis advantageous to ensure that such schemes do not perform redundantwork by compressing shared extents multiple times.

Offloading of Compression-Related Tasks to RDMA-Capable NIC

In some embodiments, servers 24, storage controllers 36, storage devices28 and/or NVRAM cache 46 (referred to collectively as “system nodes”)connect to network 32 using RDMA-capable Network Interface Controllers(NICs), sometimes referred to as RNICs. In some embodiments,computational tasks such as compression and/or decompression may beperformed by one or more of these NICs, thereby offloading the CPUs ofthe system nodes. In some embodiments the NICs comprise hardware orfirmware that performs these tasks. In other embodiments, a processor inthe NIC runs software emulation that performs these tasks.

In an example embodiment, the system nodes support an “RDMA WriteCompressed” command. This command compresses data and writes thecompressed data from an initiator node directly to the memory of atarget node. In one embodiment, the compression is performed by the NICof the initiator node, such that the completion of the “RDMA WriteCompressed” command returns the actual amount of data written to thetarget node memory. This implementation also has the benefit ofcompressing data before it is sent over network 32, thus reducingnetwork utilization and increasing the effective available throughput.

In another embodiment, the compression is performed by the NIC of thetarget node. This implementation somewhat delays the completion of thecommand, since the amount of data written needs to be reported back overthe network to the initiator node. In the latter embodiment, the trafficover network 32 is not compressed.

In another example embodiment, the system nodes support an “RDMA ReadCompressed” command. This command reads compressed data from the memoryof the target node, decompresses the data, and saves the decompresseddata to the memory of the initiator node. In one embodiment, thedecompression is performed by the NIC of the initiator node, such thatthe completion of the “RDMA Read Compressed” command returns the actualamount of data decompressed into the initiator node memory. Thisimplementation also has the benefit of transferring compressed data overthe network, thus reducing network utilization and increasing theeffective available throughput. In another embodiment, the decompressionis performed by the NIC of the target node. In the latter embodiment,the traffic sent over network 32 is not compressed.

It will be appreciated that the embodiments described above are cited byway of example, and that the present invention is not limited to whathas been particularly shown and described hereinabove. Rather, the scopeof the present invention includes both combinations and sub-combinationsof the various features described hereinabove, as well as variations andmodifications thereof which would occur to persons skilled in the artupon reading the foregoing description and which are not disclosed inthe prior art. Documents incorporated by reference in the present patentapplication are to be considered an integral part of the applicationexcept that to the extent any terms are defined in these incorporateddocuments in a manner that conflicts with the definitions madeexplicitly or implicitly in the present specification, only thedefinitions in the present specification should be considered.

1. A method for data storage, comprising: in a system that comprisesmultiple servers, multiple multi-queue storage devices and at least onestorage controller that communicate over a network, compressing by theservers data belonging to a user volume, sending the compressed datafrom the servers to the storage devices, and storing the compressed dataon the storage devices; specifying storage locations, in which thecompressed data is stored on the storage devices, in a shared datastructure that is shared and modified by the servers using remote directmemory access; and coordinating access to the compressed data by theservers by querying the shared data structure, without executing code ona processor of the storage controller.
 2. (canceled)
 3. The methodaccording to claim 1, wherein storing the compressed data comprisesaccumulating data blocks, which comprise the compressed data, in aNon-Volatile Random-Access Memory (NVRAM) cache that is accessible tothe servers and to the storage devices, so as to form one or morestripes, and transferring the stripes from the NVRAM cache to thestorage devices.
 4. The method according to claim 3, wherein storing thecompressed data comprises storing multiple compressed blocks ofcompressed data in one or more data blocks of a stripe, and whereinspecifying the storage locations comprises specifying metadata thatpoints to locations of the compressed blocks within the data blocks. 5.The method according to claim 4, and comprising storing the metadata inthe data blocks of the stripe.
 6. The method according to claim 4, andcomprising storing the metadata in the shared data structure, separatelyfrom the data blocks. 7-9. (canceled)
 10. The method according to claim1, wherein storing the compressed data comprises performing compressionor decompression in Network Interface Controllers (NICs) of the servers,the storage devices or the storage controller.
 11. A system for datastorage, comprising: multiple servers, which are configured tocommunicate over a network with multiple multi-queue storage devices andwith at least one storage controller, to compress data belonging to auser volume, to send the compressed data for storage on the storagedevices, to specify storage locations, in which the compressed data isstored on the storage devices, in a shared data structure that is sharedand modified by the servers using remote direct memory access, and tocoordinate access to the compressed data by the servers by querying theshared data structure, without executing code on a processor of thestorage controller.
 12. (canceled)
 13. The system according to claim 11,wherein the servers are configured to accumulate data blocks, whichcomprise the compressed data, in a Non-Volatile Random-Access Memory(NVRAM) cache that is accessible to the servers and to the storagedevices, so as to form one or more stripes, and to transfer the stripesfrom the NVRAM cache to the storage devices.
 14. The system according toclaim 13, wherein the servers are configured to store multiplecompressed blocks of compressed data in one or more data blocks of astripe, and to specify the storage locations by specifying metadata thatpoints to locations of the compressed blocks within the data blocks. 15.The system according to claim 14, wherein the servers are configured tostore the metadata in the data blocks of the stripe.
 16. The systemaccording to claim 14, wherein the servers are configured to store themetadata in the shared data structure, separately from the data blocks.17-19. (canceled)
 20. The system according to claim 11, wherein theservers comprise respective Network Interface Controllers (NICs) thatare configured to perform compression or decompression of the data.